<?php
session_start();
$_SESSION['time'] = time();
$ip = $_SERVER['REMOTE_ADDR'];
$_SESSION['ip'] = $ip;

if (($_SESSION['error'] == 01)){ //wrong user/pass + intentos
    $id = $_SESSION['id'];
    echo '<h1>nombre de usuario o contraseña incorrectos</h1>' ;
    switch ($_SESSION['contador']){
        case -1:
            echo 'account banned';
            session_destroy();
            header('Location:banned.php');
            break;
        case 3:
            echo 'llevas 3 intentos fallidos a los 5 te peto';
            break;
        case 5:
            echo 'your account will be banned if u fail again';
            break;
    }   
}

if ($_SESSION['error'] == 02){ //ip banned? -- implementar
    echo 'tu ip esta baneada cabron!'.  date('r').' -- '.$ip;
    unset ($_SESSION['error']);
}

if ($_SESSION['error'] == 03){
    echo 'mmm corres mucho llenando el formulario relajate o te baneo';
    echo 'tu log in esta mal por cierto';
    unset($_SESSION['error']);
    $_SESSION['bot'] = true; 
}

?>
<!doctype html>
<html lang="en">
<head>
	<meta charset="UTF-8">
	<title>test</title>
	<link rel="stylesheet" href="css/estilo.css" media="all">
</head>
<body>

	<div id="login">
		<form action= "php/processform.php" method = "post" >
			<label for="name">Nombre: </label>
			<input type="text" name = "fnick" id ="nick" value = "" maxlength = "20" size ="10"><br><br>
			<label for="pass">Password: </label>
			<input type="password" name = "fpass" id="pass" value = "" maxlength = "20" size ="10"><br>
			<input type="submit" name = "ent" value = "entrar">
		</form>
	</div>
	<div id="register">
		<form action= "php/processform.php" method = "post" >
			<label for="name">alias: </label>
			<input type="text" name = "falias" id ="nick" value = "" maxlength = "20" size ="10"><br><br>
			<label for="pass">Password: </label>
			<input type="password" name = "fpass" id="pass" value = "" maxlength = "20" size ="10"><br>
			<label for="name">Nombre: </label>
			<input type="text" name = "fname" id ="name" value = "" maxlength = "20" size ="10"><br><br>
			<label for="name">surname: </label>
			<input type="text" name = "fsurname" id ="name" value = "" maxlength = "20" size ="10"><br><br>
			<input type="submit" name = "reg" value = "registrar">
		</form>
	</div>

</body>
</html>